package org.lq.ht.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.lq.ht.dao.VipDao;
import org.lq.ht.dao.impl.VipDaoImpl;
import org.lq.ht.entity.Vip;
import org.lq.ht.service.DictionaryService;
import org.lq.ht.service.VipService;



/**
 * 	会员业务层实现
 * @author郑奥宇
 * @package org.lq.ht.service.impl
 * @date 2020年8月21日下午4:39:31
 */
public class VipServiceImpl implements VipService{
	VipDao v = new VipDaoImpl();
	VipDao vd = new VipDaoImpl();
	/**
	 * 添加
	 */
	@Override
	public boolean saveVip(Vip t) {

		return v.save(t)>0;
	}
	/**
	 * 修改
	 */
	@Override
	public boolean updateVip(Vip t) {
		return v.update(t)>0;
	}
	/**
	 * 删除
	 */
	@Override
	public boolean deleteVipById(int no) {
		return v.delete(no)>0;
	}
	/**
	 * 查询所有
	 */
	@Override
	public List<Vip> findVipAll() {
		return v.findAll();
	}
	/**
	 * 通过序号查询
	 */
	@Override
	public Vip getById(int no) {
		return v.getById(no);
	}
	
	//查询
	@Override
	public List<Vip> findVipByValue(String type,String value) {
		// TODO Auto-generated method stub
		//"所有", "卡号", "用户名", "级别", 
		List<Vip> list = null;
		switch (type) {
		case "卡号":
			list =vd.findVipByCard(value);
			break;
		case "用户名":
			list = vd.findVipByName(value);
			break;
		case "级别":
			list = vd.findVipByType(value);
			break;
		default:
			list = vd.findAll();
			break;
		}
		
		return list;
	}
	@Override
	public boolean deleteVipByVid(int vid) {
		// TODO Auto-generated method stub
		return vd.deleteByVid(vid)>0;
	}
	@Override
	public Vip getByVid(int vid) {
		// TODO Auto-generated method stub
		return vd.getByVid(vid);
	}
	@Override
	public List<Long> findAllVid() {
		// TODO Auto-generated method stub
		try {
			return vd.findAllVid();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
